#include<iostream>
#include<unordered_map>
typedef long long LL;
const int N = 1e6 + 10;
LL a[N];

int main()
{
    int T;std::cin >> T;
    while(T--)
    {
        int n;std::cin >> n;
        for(int i = 1; i <=n; i++)
        {
            std::cin >> a[i];
        }

        int left = 1, right = 1;
        int ret = 0;
        std::unordered_map<int, int> mp;
        while(right <= n)
        {
            mp[a[right]]++;
            while(mp[a[right]] > 1)
            {
                mp[a[left]]--;
                left++;
            }
            ret = std::max(ret, right - left + 1);
            right++;
        }
        std::cout << ret << std::endl;
    }
    return 0;
}
